//
//  TerminalWindowSession.m
//  Communique
//
//  Created by Thomas on 11/03/2009.
//  Copyright 2009 Delete Ltd. All rights reserved.
//
#import "Bookmark.h"
#import "PTYSession.h"
#import "TerminalWindowSession.h"

@implementation TerminalWindowSession

@synthesize bookmark=_bookmark;
@synthesize ptySession=_ptySession;
@synthesize tabViewItem=_tabViewItem;
@synthesize connected=_connected;
@synthesize ssh=_ssh;
@synthesize identifier=_identifier;

- (id) init
{
    if (self = [super init])
    {
        _bookmark = nil;
		_connected = FALSE;	
		_ssh = FALSE;	
		_ptySession = nil;
		_tabViewItem = nil;
		_identifier = 0;
    }
    return self;
}

-(void) foundString:(NSString*) string {
	if (_connected==FALSE && _ssh==TRUE) {
		[_ptySession insertText:_bookmark.password];
		[_ptySession insertNewline:nil];
		_connected = TRUE;
	}
}

-(void) setPTYSession:(PTYSession*) session {
	_ptySession = session;
	
	//if (_ssh==TRUE)
		[_ptySession setDelegate:self];
}

-(void) terminate {
	[_ptySession terminate];
	_bookmark = nil;
	_ptySession = nil;
	_tabViewItem = nil;
}

@end
